package com.julian.orderPattern;

/**
 * 测试遥控器类
 */
public class RemoteLoader {
    public static void main(String[] args) {
//        RemoteControl remoteControl = new RemoteControl();
        RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();

        Light light = new Light();
        GarageDoor garageDoor = new GarageDoor();
        Stereo stereo = new Stereo();

        LightOnCommand lightOnCommand = new LightOnCommand(light);
        LightOffCommand lightOffCommand = new LightOffCommand(light);

        GarageDoorOpenCommand openCommand = new GarageDoorOpenCommand(garageDoor);
        GarageDoorDownCommand downCommand = new GarageDoorDownCommand(garageDoor);

        StereoOnWithCDCommand stereoOnWithCDCommand = new StereoOnWithCDCommand(stereo);
        StereoOffCommand stereoOffCommand = new StereoOffCommand(stereo);

        //派对模式：同时启动关闭 灯音响车库门
        Command[] partyOn = {lightOnCommand,stereoOnWithCDCommand,openCommand};
        Command[] partyOff = {lightOffCommand,stereoOffCommand,downCommand};
        MacroCommand partyOnMacro = new MacroCommand(partyOn);
        MacroCommand partyOffMacro = new MacroCommand(partyOff);

        remoteControl.setCommands(0,lightOnCommand,lightOffCommand);
        remoteControl.setCommands(1,openCommand,downCommand);
        remoteControl.setCommands(2,stereoOnWithCDCommand,stereoOffCommand);

        remoteControl.setCommands(3,partyOnMacro,partyOffMacro);

        System.out.println(remoteControl);

        //测试开关
//        remoteControl.onButtonWasPushed(0);
//        remoteControl.offButtonWasPushed(0);
//        remoteControl.onButtonWasPushed(1);
//        remoteControl.offButtonWasPushed(1);
//        remoteControl.onButtonWasPushed(2);
//        remoteControl.offButtonWasPushed(2);

        //测试undo
//        remoteControl.onButtonWasPushed(0);
//        remoteControl.offButtonWasPushed(0);
//        System.out.println(remoteControl);
//        remoteControl.undo();
//        remoteControl.offButtonWasPushed(0);
//        remoteControl.onButtonWasPushed(0);
//        System.out.println(remoteControl);
//        remoteControl.undo();

        //测试派对模式
        System.out.println("--- Pushing Macro On --- ");
        remoteControl.onButtonWasPushed(3);
        System.out.println("--- Pushing Macro Off --- ");
        remoteControl.offButtonWasPushed(3);
        System.out.println(remoteControl);
        remoteControl.undo();
    }
}
